import SearchTablePage from '@/components/SearchTablePage';
import { PERMISSION_KEY_TERMINAL_MODULE } from '@/constants';
import {
  addTerminalModule,
  deleteTerminalModuleById,
  getTerminalModuleById,
  getTerminalModuleListByPage,
  updateTerminalModule,
} from '@/services/terminal/module';

const TerminalModule: React.FC = () => {
  return (
    <>
      <SearchTablePage<API.TerminalModule>
        tableName="设备模块"
        getRowById={getTerminalModuleById}
        updateRow={updateTerminalModule}
        addRow={addTerminalModule}
        deleteRowById={deleteTerminalModuleById}
        getRowsByPage={getTerminalModuleListByPage}
        permissionKey={PERMISSION_KEY_TERMINAL_MODULE}
        rowSelection={false}
        columns={[
          {
            title: '设备模块 ID',
            dataIndex: 'id',
            hideInTable: true,
            hideInSearch: true,
            hideInModal: true,
          },
          {
            title: '设备模块编号',
            dataIndex: 'no',
            showDetail: true,
            hideInSearch: true,
            rules: [{ required: true }],
          },
          {
            title: '模块英文名称',
            dataIndex: 'enName',
            rules: [{ required: true }],
          },
          {
            title: '模块中文名称',
            dataIndex: 'cnName',
            rules: [{ required: true }],
          },
          {
            title: '备注',
            dataIndex: 'remark',
            hideInSearch: true,
          },
          {
            title: '创建时间',
            dataIndex: 'createTime',
            valueType: 'dateTime',
            hideInSearch: true,
            hideInModal: true,
          },
        ]}
      />
    </>
  );
};

export default TerminalModule;
